﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#region License
/*
 *  Copyright (c) Dumuzi.cn 2009 , All rights reserved.
 *  CLR Version: 2.0.50727.4927
 *  NameSpace: Summer.IO
 *  Author:Edwin Tai,戴佳顺
 *  Msn:edwin19861218@hotmail.com
 *  QQ: 1961218
 *  Date:2009-11-03 13:11:38
 *  Licensed under the Microsoft Public License (Ms-PL)
 *  This license governs use of the accompanying software. 
 *  If you use the software, you accept this license.
 *  If you do not accept the license, do not use the software.
 */
#endregion

namespace Summer.IO
{
    /// <summary>
    /// File Parser that its Load and Save mehods should be overrided
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class AbstractFileParser<T>:IParser<T>
        where T:IParseableFile
    {
        /// <summary>
        /// Try to parse file to T
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public virtual T Load(string path)
        {
            return default(T);
        }
        /// <summary>
        /// Try to save T into file
        /// </summary>
        /// <param name="t"></param>
        /// <param name="path"></param>
        public virtual void Save(T t, string path)
        {
            return;
        }
        #region IParser<T> 成员

        T IParser<T>.Load(string path)
        {
           return this.Load(path);
        }

        void IParser<T>.Save(T t, string path)
        {
            this.Save(t, path);
        }

        #endregion
    }
}
